library(readstata13)
library(ggplot2)
    

recog <- read.dta13("data.dta")

reco<-recog[recog$expellee==1 & recog$estimate_share>-1,]

theme_base1 <- 
  theme_minimal(base_size=9)  + 
  theme(legend.position="none",  
        axis.text=element_text(size=13),axis.title.x=element_text(size=13),axis.title.y=element_text(size=13),
        plot.title = element_text(size=15, hjust= 0.5))

ggplot(reco, aes(x = estimate_share)) +
  geom_histogram(binwidth=10)  + geom_vline(xintercept = 30, 
                                           linetype = 2, color = "red") + ylab("# of Respondents")+
  xlab("Recognition Estimates") 
  theme_base1
ggsave("Share.pdf", width = 22, height = 18, units = "cm")  

reco$estimate[reco$estimate_share<11] <- 1
reco$estimate[reco$estimate_share>10 & reco$estimate_share<21] <- 2
reco$estimate[reco$estimate_share>20 & reco$estimate_share<31] <- 3
reco$estimate[reco$estimate_share>30 & reco$estimate_share<41] <- 4
reco$estimate[reco$estimate_share>40 & reco$estimate_share<51] <- 5
reco$estimate[reco$estimate_share>50 & reco$estimate_share<61] <- 6
reco$estimate[reco$estimate_share>60 & reco$estimate_share<71] <- 7
reco$estimate[reco$estimate_share>70 & reco$estimate_share<81] <- 8
reco$estimate[reco$estimate_share>80 & reco$estimate_share<91] <- 9
reco$estimate[reco$estimate_share>90 & reco$estimate_share<101] <- 10


ggplot(reco, aes(estimate)) + geom_bar(width=0.8) +
  scale_x_continuous(name="Recognition Estimates",limits=c(0.3,10.6), 
                     breaks = c(1,2,3,4,5,6,7,8,9,10),labels = c("0-10","11-20","21-30",
                                                                                  "31-40","41-50","51-60",
                                                                                  "61-70","71-80","81-90","91-100")) + 
  theme_base1 +
  geom_vline(xintercept = mean(reco$estimate), 
             linetype = 2, color = "red") + ylab("# of Respondents")
ggsave("Share_category.pdf", width = 22, height = 18, units = "cm")    



